package com.atguigu.guliedu.edu.service.impl;

import com.atguigu.guliedu.edu.entity.Teacher;
import com.atguigu.guliedu.edu.mapper.TeacherMapper;
import com.atguigu.guliedu.edu.service.TeacherService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 讲师 服务实现类
 * </p>
 *
 * @author java
 * @since 2021-02-01
 */
@Service
public class TeacherServiceImpl extends ServiceImpl<TeacherMapper, Teacher> implements TeacherService {

    @Override
    public Page<Teacher> listTeacher(Map<String, String> params) {
        Page<Teacher> teacherPage = new Page<Teacher>(Long.valueOf(params.get("page")),Long.valueOf(params.get("limit")));
        QueryWrapper<Teacher> queryWrapper = new QueryWrapper<>();
        String key = params.get("key");
        if(key!=null){
            queryWrapper.like("name",key);
        }
        IPage<Teacher> teacherIPage = baseMapper.selectPage(teacherPage, queryWrapper);
        return (Page)teacherIPage;
    }
}
